package io.qifan.desktop.server.domain.device.mapper;

import io.qifan.desktop.server.domain.device.Device;
import io.qifan.desktop.api.device.DeviceDto;
import io.qifan.desktop.server.domain.user.mapper.UserMapper;
import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.factory.Mappers;

@Mapper(uses = UserMapper.class)
public interface DeviceMapper {
    DeviceMapper INSTANCE = Mappers.getMapper(DeviceMapper.class);


    Device deviceDtoToDevice(DeviceDto deviceDto);

    DeviceDto deviceToDeviceDto(Device device);

    @BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
    Device updateDeviceFromDeviceDto(DeviceDto deviceDto, @MappingTarget Device device);
}
